﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace JT.WEB.Migrations.ContextWereMigrations
{
    public partial class w1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TbNameClass",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    NameClass = table.Column<string>(maxLength: 20, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TbNameClass", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TbWuPinInfo",
                columns: table => new
                {
                    NameId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    ItemName = table.Column<string>(maxLength: 20, nullable: false),
                    NameClassId = table.Column<int>(maxLength: 20, nullable: false),
                    CStandard = table.Column<string>(maxLength: 20, nullable: false),
                    Inventory = table.Column<double>(nullable: true),
                    UnitName = table.Column<string>(maxLength: 10, nullable: false),
                    UnitPrice = table.Column<double>(nullable: true),
                    Recorder = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TbWuPinInfo", x => x.NameId);
                    table.ForeignKey(
                        name: "FK_TbWuPinInfo_TbNameClass_NameClassId",
                        column: x => x.NameClassId,
                        principalTable: "TbNameClass",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "TbChuRuInfo",
                columns: table => new
                {
                    ChuRuId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    ItemNameId = table.Column<int>(nullable: false),
                    ChangeDate = table.Column<DateTime>(nullable: false),
                    Count = table.Column<double>(nullable: true),
                    IsRuKu = table.Column<int>(nullable: false),
                    Recorder = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TbChuRuInfo", x => x.ChuRuId);
                    table.ForeignKey(
                        name: "FK_TbChuRuInfo_TbWuPinInfo_ItemNameId",
                        column: x => x.ItemNameId,
                        principalTable: "TbWuPinInfo",
                        principalColumn: "NameId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_TbChuRuInfo_ItemNameId",
                table: "TbChuRuInfo",
                column: "ItemNameId");

            migrationBuilder.CreateIndex(
                name: "IX_TbWuPinInfo_NameClassId",
                table: "TbWuPinInfo",
                column: "NameClassId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TbChuRuInfo");

            migrationBuilder.DropTable(
                name: "TbWuPinInfo");

            migrationBuilder.DropTable(
                name: "TbNameClass");
        }
    }
}
